<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <div th:include="base-libs :: base-libs" />
    <title>家庭医生签约台账-导入数据</title>
    <style>
        #fileName{
            width:235px;
            font-size:15px;
            letter-spacing:1px;
            margin-left: 15px;
        }
        #fileField{
            opacity: 0;
            display:none;
        }
    </style>
    <script>
        $(function(){
            initView();
        })

        function initView(){
            /** 选择文件 */
            $("#btnXz").click(function () {
                $("#fileField").trigger("click");
            })

            /** 确定导入 */
            $("#btnQd").click(function () {
                var fileName = $("#fileName").val().trim();
                var regXls = /\.xls$/;
                if(StringUtils.isEmpty(fileName)){
                    $.QuickAlert.alertFail({content: '请选择你需要上传的Excel!'});
                }else if(!regXls.test(fileName)){
                    $.QuickAlert.alertFail({content: '请选择一个后缀名为<span style="color:red;padding:0 3px">xls</span>的Excel！'});
                }else{
                    $.QuickRemote.AjaxFiledFormSubmit("formDr", importBack, null);
                }
            })

            /** 取消导入 */
            $("#btnQx").click(function () {
                parent.layer.closeAll();
            })
        }

        /** Excle 解析回调 */
        function importBack(result){
            if(result.state){
                StoreCache.setCache("excelData",result.data);
                $("#btnQx").trigger("click");
            }else{
                $.QuickAlert.alertFail({content: result.info});
            }

        }
    </script>
</head>
<body class="easyui-layout" border="false">
    <div region="north" style="overflow: hidden" border="false">
        <h3 style="font-size:16px;padding: 8px 0px 8px 15px;">
            <span>请选择导入的文件：</span>
        </h3>
    </div>
    <!-- 导入的文件 -->
    <form id="formDr" action="parseExcalData" method="post" enctype="multipart/form-data">
        <div region="center" border="false">
            <input id='fileName' readonly="readonly" />
            <input id="fileField" type="file" name="fileField" onchange="document.getElementById('fileName').value=this.value;document.getElementById('fileName').title=this.value" />
            <button id="btnXz" class="btn btn-info" type="button" style="margin-left: 8px;position: relative;top:-1px">选择</button>
        </div>
    </form>
    <div region="south" style="height:40px;line-height:40px;border:0;border-top:1px solid #ddd;text-align: center;overflow: hidden">
        <button id="btnQd" class="btn btn-info" type="button">确定</button>
        <button id="btnQx" class="btn btn-info" type="button">取消</button>
    </div>
</body>
</html>